package com.cmower.mkyong;

/**
 * @author 沉默王二，一枚有趣的程序员
 */
public class FibonacciExampleRecursion {
    static int n1 = 0, n2 = 1, n3 = 0;

    static void printFibonacci(int count) {
        if (count > 0) {
            n3 = n1 + n2;
            n1 = n2;
            n2 = n3;
            System.out.print(" " + n3);

            // 之前打印了一个
            printFibonacci(count - 1);
        }
    }

    public static void main(String[] args) {
        int count = 10;

        // 打印 0 1
        System.out.print(n1 + " " + n2);
        // 已经打印了 2 个
        printFibonacci(count - 2);
    }
}
